/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: AliceMana
 * Date: 2022-12-31
 * Time: 1:53
 */
public class Solution3 {
    // https://leetcode.cn/problems/add-digits/
    public static int addDigits(int num) {
        while (num > 9) {
            int ret = 0;
            while (num != 0) {
                ret += (num % 10);
                num /= 10;
            }
            num = ret;
        }
        return num;
    }

    public static void main(String[] args) {
        System.out.println(addDigits(0));
    }
}
